#ifndef SEGMENTDATAPARSER_H_
#define SEGMENTDATAPARSER_H_

#include "status.hxx"
#include <string>

class Dbt;

class SegmentDataParser {

public:
	//search data by key, return the matched valye, the data following a layout of segment
	static bool getValueByKey(const std::string& key, const std::string& data, std::string& value);
    static bool getValueByKeyDbt(Dbt& key, Dbt& data, Dbt& value);

	//remove key/value pair from data by key
	static void removeByKey(const std::string& key, std::string& data);
    static void removeByKeyDbt(Dbt& key, Dbt& data);

	//covert key/value to data follwing the layout of segment 
	static std::string serialize(const std::string& key, const std::string& value);
    static Dbt serializeDbt(Dbt& key, Dbt& value, Dbt& result);

	//based on data, covert key/value to a new data follwing the layout of segment 
	static std::string serialize(const std::string& key, const std::string& value,  std::string& data);
    static Dbt serializeDbtFromDbt(Dbt& key, Dbt& value, Dbt& data);
};

#endif
